home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / DirectDraw / WindowedMode / readme.txt < prev    next >
Encoding:
Text File  |  2001-10-10  |  4.2 KB  |  85 lines

  1. //-----------------------------------------------------------------------------
  2. // 
  3. // Sample Name: WindowedMode Sample
  4. // 
  5. // Copyright (c) 1999-2001 Microsoft Corporation. All rights reserved.
  6. // 
  7. //-----------------------------------------------------------------------------
  8.  
  9.  
  10. Description
  11. ===========
  12.   WindowedMode demonstrates the tasks required to initialize and run 
  13.   a windowed DirectDraw application.
  14.  
  15. Path
  16. ====
  17.   Source: DXSDK\Samples\Multimedia\DDraw\WindowedMode
  18.  
  19.   Executable: DXSDK\Samples\Multimedia\DDraw\Bin
  20.  
  21. User's Guide
  22. ============
  23.   WindowedMode requires no user input. Press the ESC key to quit the program.
  24.  
  25. Programming Notes
  26. =================
  27.   The basic tasks to author a simple windowed DirectDraw application are as follows:
  28.   
  29.   Initialize DirectDraw: 
  30.     1. Register a window class and create a window.   
  31.     2. Call DirectDrawCreateEx to create a DirectDraw object
  32.     3. Call SetCooperativeLevel to set the DirectDraw cooperative level 
  33.        to normal.
  34.     4. Call CreateSurface to obtain a pointer to the primary surface.  In windowed mode,
  35.        the primary surface is also the desktop window.  So the pixel format for the 
  36.        primary surface is based on the user's selection of display resolution. 
  37.     5. Create a back-buffer.  In windowed mode, this is should be an off-screen 
  38.        plain buffer. The back buffer is typically the same size as the window's 
  39.        client rect, but could be created with any size.  
  40.     6. Test to see if the display mode is in palettized color (8-bit or less).  
  41.        If it is then a palette needs to be created. This sample displays a single 
  42.        bitmap so it can read the bitmap palette info to read and create a DirectDraw 
  43.        palette.  After a palette is created, call SetPalette to set the palette for 
  44.        the primary surface. 
  45.     7. Call CreateClipper and SetClipper to create a clipper object, and attach it
  46.        to the primary surface.  This will keep DirectDraw from blting on top of 
  47.        any windows which happen to overlap.      
  48.     8. Create an off-screen plain DirectDraw surface, and load media content into it.  
  49.        For example, this sample calls DDUtil_CreateSurfaceFromBitmap() to do just 
  50.        this. 
  51.  
  52.   When the app is idle, and it is not hidden or minimized then render the 
  53.   next frame by:
  54.     1. If movement or animation is involved in the app, then calculate how much 
  55.        time has passed since the last time the frame was displayed.
  56.     2. Move or animate the app state based on how much time has passed.
  57.     3. Draw the current state into the off-screen plain backbuffer.
  58.     4. Call Blt to blt the contents of the off-screen plain backbuffer into 
  59.        the primary surface.
  60.   
  61.   If the display resolution changes or an exclusive mode DirectDraw app is run, then 
  62.   the DirectDraw surface may be lost (resulting in a DirectDraw call returning 
  63.   DDERR_SURFACELOST), then handle it by:
  64.     1. Call RestoreAllSurfaces to have DirectDraw restore all the surfaces.  
  65.     2. Restoring a surface doesn't reload any content that existed in the surface 
  66.        prior to it being lost. So you must now redraw the graphics the surfaces 
  67.        once held.  For example, this sample handles this by calling 
  68.        DDUtil_ReDrawBitmapOnDDS()
  69.  
  70.   In windowed mode, handle the following windows messages:
  71.     1. WM_PAINT: This is sent when all or a part of the window is needs to be 
  72.        redrawn.  The app may not be active at the time this is called, so if this 
  73.        is not handled then the window will appear blank.  To avoid this, make a 
  74.        call to draw the next frame here.
  75.     2. WM_QUERYNEWPALETTE: This is sent when in a 8-bit desktop and the another 
  76.        window set a new palette, but now this window has control so it needs to reset
  77.        its palette.  The easy way to make this happen in DirectDraw is just to call
  78.        SetPalette.  This will force DirectDraw to realize the DirectDrawPalette 
  79.        attached to it. 
  80.     3. WM_MOVE: This is sent when the window is moving.  Record the new window position
  81.        here since the blt to the primary surface needs to know the window position.
  82.       
  83.       
  84.       
  85.